﻿<?php

class TRelManutencao
{
    private $conteudo;
    
    public function __construct(array $conteudo) 
    {
        $this->conteudo = $conteudo;       
    }
        
    public function render()
    {
//        if(!$this->conteudo)
//        {
//            include_once 'app.ado/DataBase.php';
//            $pdo = new DataBase();
//            $db = $pdo->getConn();
//            
//            $sql = 'select * from req_manutencoes';
//            
//            if($this->dt_inicial or $this->dt_final)
//            {
//                $this->dt_inicial = $this->dt_inicial ? $this->dt_inicial : '2012/01/01';
//                $this->dt_final = $this->dt_final ? $this->dt_final : date('Y/m/d');
//                
//                $sql .= ' where (dt_requisicao between ? and ?)';
//                
//                $exec[] = $this->dt_inicial;
//                $exec[] = $this->dt_final;
//                
//                if($this->id)
//                {
//                    $sql .= ' and id_requisicao = ?';
//                    $exec[] = $this->id;
//                }
//            }
//            elseif($this->id)
//            {
//                $sql .= ' where id_requisicao = ?';
//                $exec[] = $this->id;
//            }
//            
//            if($this->order)
//            {
//                $sql .= ' order by ?';
//                $exec[] = $this->order;
//            }
//            
//            $sth = $db->prepare($sql);
//            $conteudo = $sth->execute($exec);
//            $this->conteudo = $conteudo->fetchAll(PDO::FETCH_CLASS, 'Requerir');
//        }
        
        $html = '';
        foreach ($this->conteudo as $requisicao)
        {
            $tabela = new TTableManutencao($requisicao);
            $html .= $tabela->render();
        }

        //var_dump($html);
        $pdf = new TRelatorio();
        
        $pdf->pdf->WriteHTML(utf8_encode($html));
        $pdf->pdf->Output('manutencoes '.date('d m Y').'.pdf','D');
        //header('location: index.php');
    }
}


?>
